Imports System.Data
Partial Class Admin_frmModifySubCategory
    Inherits System.Web.UI.Page
    Dim VarSubCategoryId As String
    Dim _SubCategoryVO As New SubCategoryVo
    Dim _BO As New Bo
    Dim _EmployeeId As String
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        _EmployeeId = Session("EmpId")
        If _EmployeeId = "" Then
            Response.Redirect("../Client/frmLogin.aspx")
        End If
        VarSubCategoryId = Request.QueryString("SubCategoryId")
        If VarSubCategoryId = "" Then
            Response.Redirect("frmTabSubCategory.aspx")
        Else
            If Not IsPostBack Then
                GetSubCategoryData()
                CategoryData()
            End If
        End If
    End Sub

    Sub GetSubCategoryData()
        _SubCategoryVO = _BO.getSubCategoryById(VarSubCategoryId)
        ddlCategory.SelectedValue = _SubCategoryVO.CategoryId
        ddlCategory.Text = _SubCategoryVO.CategoryId
        lblSubCategoryId.Text = _SubCategoryVO.SubCategoryId
        txtSubCategoryName.Text = _SubCategoryVO.SubCategoryName
    End Sub
    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        CategoryData()
        SetData()
        Session("EmpId") = _EmployeeId
    End Sub
    Sub SetData()
        'MsgBox(ddlCategory.Text)
        _SubCategoryVO.CategoryId = ddlCategory.SelectedValue
        _SubCategoryVO.SubCategoryId = lblSubCategoryId.Text
        _SubCategoryVO.SubCategoryName = txtSubCategoryName.Text
        _BO.ModifySubCategory(_SubCategoryVO)
        ClearAll()
    End Sub
    Public Sub ClearAll()
        txtSubCategoryName.Text = ""
        MsgBox("SubCategory Modified")
        Response.Redirect("frmTabSubCategory.aspx", False)
    End Sub
    Public Sub CategoryData()
        Dim dtCategory As DataTable
        dtCategory = _BO.getcategory()
        ddlCategory.DataSource = dtCategory
        ddlCategory.DataValueField = dtCategory.Columns(0).ToString
        ddlCategory.DataTextField = dtCategory.Columns(1).ToString
        ddlCategory.DataBind()
    End Sub

    Protected Sub btnReset_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnReset.Click
        txtSubCategoryName.Text = ""
    End Sub
End Class
